package br.com.sgac.dao;

import java.util.Calendar;
import java.util.Date;

import javax.persistence.Query;
import javax.persistence.TemporalType;

import br.com.sgac.model.Agenda;
import br.com.sgac.model.Medico;

public class AgendaDAO extends GenericDAO<Agenda> {

	public AgendaDAO() {
		super();
	}

	public Agenda findAgendaByMedicoData(String nome, Date data){
		Agenda agenda = new Agenda();
		//return (Agenda) super.findByQuery("select a from Agenda a where a.medico.id = "+medico.getId()+" and a.dataAgendamento = '"+data+"'");
		Query query = super.getManager().createQuery("select a from Agenda a where a.medico.nome = '"+nome+"' and a.dataAgendamento = ?1");
		query.setParameter(1, data, TemporalType.DATE);
		agenda = (Agenda)query.getSingleResult();
		return agenda;
	}	
	
}
